import React, { useEffect, useState } from 'react'
import { listApi } from '../../api'
function Index() {
    const [data,setData]=useState([])
    const [page,setPage]=useState(1)

    const getData=async()=>{
        const resp=await listApi(data)
        console.log(resp.data.data)

       setData(data.concat(resp.data.data))
       setPage(page+1)
    }
    useEffect(()=>{
        getData()
    },[])
  return (
    <div>
      {
        data.map((v,i)=>{
            return <dl key={i}>
                <dt>
                    <img src={v.image} alt="" />
                </dt>
                <dd>
                    <h4>{v.title}</h4>
                    <p>{v.price}</p>
                    <p>{v.date}</p>
                </dd>
            </dl>
        })
      }
    </div>
  )
}

export default Index
